package cn.edu.swu.book;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/DeleteBook")
public class DeleteBookServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id=req.getParameter("bookId");
        try {
            bookRepo.getInstance().deleteBook(id);
            resp.sendRedirect("./index-simple.html");
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
